package com.ruoyi.asset.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.asset.domain.AssetFlowStep;
import com.ruoyi.asset.service.IAssetFlowStepService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 审核流程Controller
 * 
 * @author yepanpan
 * @date 2024-12-25
 */
@RestController
@RequestMapping("/asset/flowStep")
public class AssetFlowStepController extends BaseController
{
    @Autowired
    private IAssetFlowStepService assetFlowStepService;

    /**
     * 查询审核流程列表
     */
    @PreAuthorize("@ss.hasPermi('asset:flowStep:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssetFlowStep assetFlowStep)
    {
        startPage();
        List<AssetFlowStep> list = assetFlowStepService.selectAssetFlowStepList(assetFlowStep);
        return getDataTable(list);
    }

    /**
     * 导出审核流程列表
     */
    @PreAuthorize("@ss.hasPermi('asset:flowStep:export')")
    @Log(title = "审核流程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AssetFlowStep assetFlowStep)
    {
        List<AssetFlowStep> list = assetFlowStepService.selectAssetFlowStepList(assetFlowStep);
        ExcelUtil<AssetFlowStep> util = new ExcelUtil<AssetFlowStep>(AssetFlowStep.class);
        util.exportExcel(response, list, "审核流程数据");
    }

    /**
     * 获取审核流程详细信息
     */
    @PreAuthorize("@ss.hasPermi('asset:flowStep:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(assetFlowStepService.selectAssetFlowStepById(id));
    }

    /**
     * 新增审核流程
     */
    @PreAuthorize("@ss.hasPermi('asset:flowStep:add')")
    @Log(title = "审核流程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AssetFlowStep assetFlowStep)
    {
        return toAjax(assetFlowStepService.insertAssetFlowStep(assetFlowStep));
    }

    /**
     * 修改审核流程
     */
    @PreAuthorize("@ss.hasPermi('asset:flowStep:edit')")
    @Log(title = "审核流程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AssetFlowStep assetFlowStep)
    {
        return toAjax(assetFlowStepService.updateAssetFlowStep(assetFlowStep));
    }

    /**
     * 删除审核流程
     */
    @PreAuthorize("@ss.hasPermi('asset:flowStep:remove')")
    @Log(title = "审核流程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(assetFlowStepService.deleteAssetFlowStepByIds(ids));
    }
}
